package com.xhwl.data.controller;

import com.xhwl.common.dto.cent.sdata.RoomManageTypeDTO;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.query.cent.sdata.RoomManageTypeQuery;
import com.xhwl.data.service.IRoomManageTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author yf
 * @Description:
 * @Date Create in 11:07 2022/06/13
 */
@RestController
public class RoomManageTypeController {
    @Autowired
    private IRoomManageTypeService roomManageTypeService;

    /**
     * 新增/更新
     *
     * @param roomManageTypeDTO
     * @return
     */
    @RequestMapping(value = "/room-manage-type/create", method = RequestMethod.POST)
    ResultJson create(@RequestBody RoomManageTypeDTO roomManageTypeDTO) {
        if (null == roomManageTypeDTO.getId()) {
            return roomManageTypeService.create(roomManageTypeDTO);
        } else {
            return roomManageTypeService.update(roomManageTypeDTO);
        }
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @RequestMapping(value = "/room-manage-type/delete", method = RequestMethod.POST)
    ResultJson delete(Integer id) {
        return roomManageTypeService.delete(id);
    }

    /**
     * 分页
     *
     * @param roomManageTypeQuery
     * @return
     */
    @RequestMapping(value = "/room-manage-type/page", method = RequestMethod.POST)
    ResultJson page(@RequestBody RoomManageTypeQuery roomManageTypeQuery) {
        return ResultJson.success(roomManageTypeService.page(roomManageTypeQuery));
    }
}
